import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class CsvWritter2 {

    public static void main(String[] args) {
        // 定义边界值
        int[] boundaries = {1, 2, 50,99, 100};

        String folderPath = ""; // 当前目录
        String fileName = "triangle3.csv";
        String csvFile = folderPath.isEmpty() ? fileName : folderPath + File.separator + fileName;

        // 生成 CSV 文件
        try (FileWriter writer = new FileWriter(csvFile)) {


            // 生成所有边界值组合
            for (int a : boundaries) {

            for (int b : boundaries) {

                for (int c : boundaries) {
                    // 判断是否为三角形
                    String isTriangle = isTriangle(a, b, c);
                    // 写入一行数据
                    writer.write(a + "," + b + "," + c + "," + isTriangle + "," + "\n");
                }
            }}


            System.out.println("CSV 文件生成成功：" + csvFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // 判断是否为三角形
    private static String isTriangle(int a, int b, int c) {
        if (a <1 || a>100 || b<1 || b>100 || c<1 || c> 100) {
            return "输入错误";
        }
        if (!((a + b > c) && (a + c > b) && (b + c > a))) {
            return "非三角形";
        } else if (a == b && a == c && b == c) {
            return "等边三角形";
        } else if (a != b && a != c && b != c) {
            return "一般三角形";
        } else {
            return "等腰三角形";
        }
    }
}